<?php

session_start();
chdir('../..');

if (!$_SESSION['is_connect']) {
	echo 'forbidden';
	return;
}


if (isset($_POST['action'])) {

	switch ($_POST['action']) {	
	
		case 'preview':
			require_once('pages/annonces/_bbcode.php');
			require_once('lib/utils.php');
			echo '<div class="post-preview">';
			print_bb_code(clean_str($_POST['content']));
			echo '</div>';
			break;
			
		case 'delete_answer':
			if ($_SESSION['status'] == 'O' || $_SESSION['status'] == 'A') {
				require_once('lib/constants.php');
				require_once('lib/utils.php');
				require_once('lib/mysql.php');
				require_once('lib/post.php');
				sql_connect();
				ann_delete_answer($_POST['id']);
			}
			break;
	}
}
else {
	echo 'fail';
}
